<?php

/**
 * RP System
 *
 * @version 1.0
 * @copyright 2004 Ron Planken
 */

class static_page {
	function get($static_id = 0) {

		global $dbh;

		if ($news_id == 0) {
			$query ="SELECT static_id
						   ,static_string
						   ,subject
						   ,date_time_posted
						   ,text_body
					   FROM static_page
				   ORDER BY date_time_posted DESC
							";
		} else {
			$query ="SELECT static_id
						   ,static_string
						   ,subject
						   ,date_time_posted
						   ,text_body
					   FROM static_page
					  WHERE static_id = $static_id
							";
		}
		$staticPages = selectMultiQuery($query, $dbh);

		return $staticPages;
	}

	function save($static_id = 0, $static_string = "", $subject = "", $user_id = 0, $date_time_posted = "", $text_body = "") {

		global $dbh;

		$static_string = secure_string($static_string);
		$subject = secure_string($subject);
		$user_id = secure_int($user_id);
		$text_body = secure_string($text_body);

		if ($static_id == 0) {

			$static_id = secure_int($static_id);

			$query ="INSERT INTO static_page
						   (static_string
						   ,subject
						   ,poster_id
						   ,date_time_posted
						   ,text_body)
					VALUES ($static_string
						   ,$subject
						   ,$user_id
						   ,$date_time_posted
						   ,$text_body)
							";
			$status = InsertQuery($query, $dbh);
		} else {
			$query ="UPDATE static_page
						SET static_string = $static_string
						   ,subject = $subject
						   ,player_id = $player_id
						   ,date_time_posted = $date_time_posted
						   ,text_body = $text_body
					  WHERE static_id = $static_id
							";
			$status = UpdateQuery($query, $dbh);
		}

		return $status;

	}
	

	function remove($static_id = 0) {

		global $dbh;
		
		$static_id = secure_int($static_id);
		
		$query ="DELETE FROM static_page
				  	   WHERE static_id = $static_id;
							";
		$status = UpdateQuery($query, $dbh);

		return $status;
	}
	
}
?>